/****************************************************************
 * Fulguro
 * Copyright (C) 2004 Christophe Clienti
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; eif not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 ***************************************************************/

#include <flgrCoreData.h>
#include <flgrCoreIO.h>
#include <flgrCoreCopy.h>
#include <flgrCoreShift.h>
#include <flgrCoreDispatch.h>
#include <flgrCoreReplace.h>
#include <flgrArith.h>
#include "flgrMorphoSkizFast.h"


#ifdef __SSE2__
#include <emmintrin.h>
#endif

#if defined(__SSE__) && defined(__MMX__)
#include <xmmintrin.h>
#include <mmintrin.h>
#endif

#define rep_dil(pcenter,pdil,pnx) (((*pcenter != *pdil) && (*pnx != 0) && (*pnx != *pdil)) ? 0 : *pdil)

#define FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_6			\
  int i;								\
									\
  for(i=0 ; i<length ; i++) {						\
    if(pcenter[i] != pdil[i] ) {					\
      if((pn3[i] != 0) && (pn3[i] != pdil[i]) && (i!=0)) {		\
	pdil[i] = 0; continue;						\
      }									\
      if((pn4[i] != 0) && (pn4[i] != pdil[i])) {			\
	pdil[i] = 0; continue;						\
      }									\
      if((pn5[i] != 0) && (pn5[i] != pdil[i]) && (i!=length-1)) {	\
	pdil[i] = 0; continue;						\
      }									\
      if((pn6[i] != 0) && (pn6[i] != pdil[i]) && (i!=0)) {		\
	pdil[i] = 0; continue;						\
      }									\
      if((pn7[i] != 0) && (pn7[i] != pdil[i])) {			\
	pdil[i] = 0; continue;						\
      }									\
      if((pn8[i] != 0) && (pn8[i] != pdil[i]) && (i!=length-1)) {	\
	pdil[i] = 0; continue;						\
      }									\
    }									\
  }									\
  ;



#define FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_9			\
  int i;								\
									\
  for(i=0 ; i<length ; i++) {						\
    if(pcenter[i] != pdil[i] ) {					\
      if((pn0[i] != 0) && (pn0[i] != pdil[i]) && (i!=0)) {		\
	pdil[i] = 0; continue;						\
      }									\
      if((pn1[i] != 0) && (pn1[i] != pdil[i])) {			\
	pdil[i] = 0; continue;						\
      }									\
      if((pn2[i] != 0) && (pn2[i] != pdil[i]) && (i!=length-1)) {	\
	pdil[i] = 0; continue;						\
      }									\
      if((pn3[i] != 0) && (pn3[i] != pdil[i]) && (i!=0)) {		\
	pdil[i] = 0; continue;						\
      }									\
      if((pn4[i] != 0) && (pn4[i] != pdil[i])) {			\
	pdil[i] = 0; continue;						\
      }									\
      if((pn5[i] != 0) && (pn5[i] != pdil[i]) && (i!=length-1)) {	\
	pdil[i] = 0; continue;						\
      }									\
      if((pn6[i] != 0) && (pn6[i] != pdil[i]) && (i!=0)) {		\
	pdil[i] = 0; continue;						\
      }									\
      if((pn7[i] != 0) && (pn7[i] != pdil[i])) {			\
	pdil[i] = 0; continue;						\
      }									\
      if((pn8[i] != 0) && (pn8[i] != pdil[i]) && (i!=length-1)) {	\
	pdil[i] = 0; continue;						\
      }									\
    }									\
  }									\
  ;



#define FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_6_SIMD(vtype,vsize,	\
							cmp_instr,set1_instr, \
							and_instr,or_instr) \
  int i;								\
  vtype vec_pnx;							\
  vtype vec_center;							\
  vtype vec_dil;							\
  vtype vec_cmp1;							\
  vtype vec_cmp2;							\
  vtype vec_zero = set1_instr(0);					\
									\
  *pdil = rep_dil(pcenter,pdil,pn4);					\
  *pdil = rep_dil(pcenter,pdil,pn5);					\
  *pdil = rep_dil(pcenter,pdil,pn7);					\
  *pdil = rep_dil(pcenter,pdil,pn8);					\
									\
  pcenter++;								\
  pdil++;								\
  pn3++;								\
  pn4++;								\
  pn5++;								\
  pn6++;								\
  pn7++;								\
  pn8++;								\
									\
  for(i=1 ; i<vsize ; i++) {						\
    *pdil = rep_dil(pcenter,pdil,pn3);					\
    *pdil = rep_dil(pcenter,pdil,pn4);					\
    *pdil = rep_dil(pcenter,pdil,pn5);					\
    *pdil = rep_dil(pcenter,pdil,pn6);					\
    *pdil = rep_dil(pcenter,pdil,pn7);					\
    *pdil = rep_dil(pcenter,pdil,pn8);					\
    pdil++;								\
    pcenter++;								\
    pn3++;								\
    pn4++;								\
    pn5++;								\
    pn6++;								\
    pn7++;								\
    pn8++;								\
  }	 								\
									\
  for(i=vsize ; i<length-vsize ; i+=vsize) {				\
    vec_center = *((vtype*) pcenter);					\
    vec_dil  = *((vtype*) pdil);					\
    vec_cmp1 = cmp_instr(vec_center,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn3);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn4);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn5);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn6);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn7);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn8);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    *((vtype*) pdil)=vec_dil;						\
									\
    pcenter += vsize;							\
    pdil += vsize;							\
    pn3 += vsize;							\
    pn4 += vsize;							\
    pn5 += vsize;							\
    pn6 += vsize;							\
    pn7 += vsize;							\
    pn8 += vsize;							\
  }									\
  									\
  for( ; i<length-1 ; i++) {						\
    *pdil = rep_dil(pcenter,pdil,pn3);					\
    *pdil = rep_dil(pcenter,pdil,pn4);					\
    *pdil = rep_dil(pcenter,pdil,pn5);					\
    *pdil = rep_dil(pcenter,pdil,pn6);					\
    *pdil = rep_dil(pcenter,pdil,pn7);					\
    *pdil = rep_dil(pcenter,pdil,pn8);					\
    pdil++;								\
    pcenter++;								\
    pn3++;								\
    pn4++;								\
    pn5++;								\
    pn6++;								\
    pn7++;								\
    pn8++;								\
  }	 								\
									\
  *pdil = rep_dil(pcenter,pdil,pn3);					\
  *pdil = rep_dil(pcenter,pdil,pn4);					\
  *pdil = rep_dil(pcenter,pdil,pn6);					\
  *pdil = rep_dil(pcenter,pdil,pn7)


#define FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_9_SIMD(vtype,vsize,	\
							cmp_instr,set1_instr, \
							and_instr,or_instr) \
  int i;								\
  vtype vec_pnx;							\
  vtype vec_center;							\
  vtype vec_dil;							\
  vtype vec_cmp1;							\
  vtype vec_cmp2;							\
  vtype vec_zero = set1_instr(0);					\
									\
  *pdil = rep_dil(pcenter,pdil,pn1);					\
  *pdil = rep_dil(pcenter,pdil,pn2);					\
  *pdil = rep_dil(pcenter,pdil,pn4);					\
  *pdil = rep_dil(pcenter,pdil,pn5);					\
  *pdil = rep_dil(pcenter,pdil,pn7);					\
  *pdil = rep_dil(pcenter,pdil,pn8);					\
									\
  pcenter++;								\
  pdil++;								\
  pn0++;								\
  pn1++;								\
  pn2++;								\
  pn3++;								\
  pn4++;								\
  pn5++;								\
  pn6++;								\
  pn7++;								\
  pn8++;								\
									\
  for(i=1 ; i<vsize ; i++) {						\
    *pdil = rep_dil(pcenter,pdil,pn0);					\
    *pdil = rep_dil(pcenter,pdil,pn1);					\
    *pdil = rep_dil(pcenter,pdil,pn2);					\
    *pdil = rep_dil(pcenter,pdil,pn3);					\
    *pdil = rep_dil(pcenter,pdil,pn4);					\
    *pdil = rep_dil(pcenter,pdil,pn5);					\
    *pdil = rep_dil(pcenter,pdil,pn6);					\
    *pdil = rep_dil(pcenter,pdil,pn7);					\
    *pdil = rep_dil(pcenter,pdil,pn8);					\
    pdil++;								\
    pcenter++;								\
    pn0++;								\
    pn1++;								\
    pn2++;								\
    pn3++;								\
    pn4++;								\
    pn5++;								\
    pn6++;								\
    pn7++;								\
    pn8++;								\
  }	 								\
									\
  for(i=vsize ; i<length-vsize ; i+=vsize) {				\
    vec_center = *((vtype*) pcenter);					\
    vec_dil  = *((vtype*) pdil);					\
    vec_cmp1 = cmp_instr(vec_center,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn0);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn1);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn2);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn3);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn4);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn5);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn6);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn7);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn8);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    *((vtype*) pdil) = vec_dil;						\
									\
    pcenter += vsize;							\
    pdil += vsize;							\
    pn0 += vsize;							\
    pn1 += vsize;							\
    pn2 += vsize;							\
    pn3 += vsize;							\
    pn4 += vsize;							\
    pn5 += vsize;							\
    pn6 += vsize;							\
    pn7 += vsize;							\
    pn8 += vsize;							\
  }									\
									\
  for( ; i<length-1 ; i++) {						\
    *pdil = rep_dil(pcenter,pdil,pn0);					\
    *pdil = rep_dil(pcenter,pdil,pn1);					\
    *pdil = rep_dil(pcenter,pdil,pn2);					\
    *pdil = rep_dil(pcenter,pdil,pn3);					\
    *pdil = rep_dil(pcenter,pdil,pn4);					\
    *pdil = rep_dil(pcenter,pdil,pn5);					\
    *pdil = rep_dil(pcenter,pdil,pn6);					\
    *pdil = rep_dil(pcenter,pdil,pn7);					\
    *pdil = rep_dil(pcenter,pdil,pn8);					\
    pdil++;								\
    pcenter++;								\
    pn0++;								\
    pn1++;								\
    pn2++;								\
    pn3++;								\
    pn4++;								\
    pn5++;								\
    pn6++;								\
    pn7++;								\
    pn8++;								\
  }	 								\
									\
  *pdil = rep_dil(pcenter,pdil,pn0);					\
  *pdil = rep_dil(pcenter,pdil,pn1);					\
  *pdil = rep_dil(pcenter,pdil,pn3);					\
  *pdil = rep_dil(pcenter,pdil,pn4);					\
  *pdil = rep_dil(pcenter,pdil,pn6);					\
  *pdil = rep_dil(pcenter,pdil,pn7)


			  










inline void flgr_stop_label_collision_8_connex_6_fgUINT8(fgUINT8 *pn3, fgUINT8 *pn4, fgUINT8 *pn5,
							 fgUINT8 *pn6, fgUINT8 *pn7, fgUINT8 *pn8,
							 fgUINT8 *pdil, fgUINT8 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_6_SIMD(__m128i,16,
						  _mm_cmpeq_epi8,_mm_set1_epi8, 
						  _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_6_SIMD(__m64,8,
						  _mm_cmpeq_pi8,_mm_set1_pi8, 
						  _mm_and_si64,_mm_or_si64);
  _mm_empty();
#else
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_6;
#endif
#endif
}


inline void flgr_stop_label_collision_8_connex_9_fgUINT8(fgUINT8 *pn0, fgUINT8 *pn1, fgUINT8 *pn2,
							 fgUINT8 *pn3, fgUINT8 *pn4, fgUINT8 *pn5,
							 fgUINT8 *pn6, fgUINT8 *pn7, fgUINT8 *pn8,
							 fgUINT8 *pdil, fgUINT8 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_9_SIMD(__m128i,16,
						  _mm_cmpeq_epi8,_mm_set1_epi8,
						  _mm_and_si128,_mm_or_si128);
  
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_9_SIMD(__m64,8,
						  _mm_cmpeq_pi8,_mm_set1_pi8, 
						  _mm_and_si64,_mm_or_si64);
  _mm_empty();
#else
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_9;
#endif
#endif
}










inline void flgr_stop_label_collision_8_connex_6_fgUINT16(fgUINT16 *pn3, fgUINT16 *pn4, fgUINT16 *pn5,
							  fgUINT16 *pn6, fgUINT16 *pn7, fgUINT16 *pn8,
							  fgUINT16 *pdil, fgUINT16 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_6_SIMD(__m128i,8,
						  _mm_cmpeq_epi16,_mm_set1_epi16,
						  _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_6_SIMD(__m64,4,
						  _mm_cmpeq_pi16,_mm_set1_pi16, 
						  _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_6;
#endif
#endif
}


inline void flgr_stop_label_collision_8_connex_9_fgUINT16(fgUINT16 *pn0, fgUINT16 *pn1, fgUINT16 *pn2,
							  fgUINT16 *pn3, fgUINT16 *pn4, fgUINT16 *pn5,
							  fgUINT16 *pn6, fgUINT16 *pn7, fgUINT16 *pn8,
							  fgUINT16 *pdil, fgUINT16 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_9_SIMD(__m128i,8,
						  _mm_cmpeq_epi16,_mm_set1_epi16,
						  _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_9_SIMD(__m64,4,
						  _mm_cmpeq_pi16,_mm_set1_pi16, 
						  _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_9;
#endif
#endif
}









inline void flgr_stop_label_collision_8_connex_6_fgUINT32(fgUINT32 *pn3, fgUINT32 *pn4, fgUINT32 *pn5,
							  fgUINT32 *pn6, fgUINT32 *pn7, fgUINT32 *pn8,
							  fgUINT32 *pdil, fgUINT32 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_6_SIMD(__m128i,4,
						  _mm_cmpeq_epi32,_mm_set1_epi32,
						  _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_6_SIMD(__m64,2,
						  _mm_cmpeq_pi32,_mm_set1_pi32, 
						  _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_6;
#endif
#endif
}


inline void flgr_stop_label_collision_8_connex_9_fgUINT32(fgUINT32 *pn0, fgUINT32 *pn1, fgUINT32 *pn2,
							  fgUINT32 *pn3, fgUINT32 *pn4, fgUINT32 *pn5,
							  fgUINT32 *pn6, fgUINT32 *pn7, fgUINT32 *pn8,
							  fgUINT32 *pdil, fgUINT32 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_9_SIMD(__m128i,4,
						  _mm_cmpeq_epi32,_mm_set1_epi32,
						  _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_9_SIMD(__m64,2,
						  _mm_cmpeq_pi32,_mm_set1_pi32, 
						  _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_9;
#endif
#endif
}




















inline void flgr_stop_label_collision_8_connex_6_fgINT8(fgINT8 *pn3, fgINT8 *pn4, fgINT8 *pn5,
							fgINT8 *pn6, fgINT8 *pn7, fgINT8 *pn8,
							fgINT8 *pdil, fgINT8 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_6_SIMD(__m128i,16,
						  _mm_cmpeq_epi8,_mm_set1_epi8, 
						  _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_6_SIMD(__m64,8,
						  _mm_cmpeq_pi8,_mm_set1_pi8, 
						  _mm_and_si64,_mm_or_si64);
  _mm_empty();
#else
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_6;
#endif
#endif
}


inline void flgr_stop_label_collision_8_connex_9_fgINT8(fgINT8 *pn0, fgINT8 *pn1, fgINT8 *pn2,
							fgINT8 *pn3, fgINT8 *pn4, fgINT8 *pn5,
							fgINT8 *pn6, fgINT8 *pn7, fgINT8 *pn8,
							fgINT8 *pdil, fgINT8 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_9_SIMD(__m128i,16,
						  _mm_cmpeq_epi8,_mm_set1_epi8,
						  _mm_and_si128,_mm_or_si128);

#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_9_SIMD(__m64,8,
						  _mm_cmpeq_pi8,_mm_set1_pi8, 
						  _mm_and_si64,_mm_or_si64);
  _mm_empty();
#else
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_9;
#endif
#endif
}










inline void flgr_stop_label_collision_8_connex_6_fgINT16(fgINT16 *pn3, fgINT16 *pn4, fgINT16 *pn5,
							 fgINT16 *pn6, fgINT16 *pn7, fgINT16 *pn8,
							 fgINT16 *pdil, fgINT16 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_6_SIMD(__m128i,8,
						  _mm_cmpeq_epi16,_mm_set1_epi16,
						  _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_6_SIMD(__m64,4,
						  _mm_cmpeq_pi16,_mm_set1_pi16, 
						  _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_6;
#endif
#endif
}


inline void flgr_stop_label_collision_8_connex_9_fgINT16(fgINT16 *pn0, fgINT16 *pn1, fgINT16 *pn2,
							 fgINT16 *pn3, fgINT16 *pn4, fgINT16 *pn5,
							 fgINT16 *pn6, fgINT16 *pn7, fgINT16 *pn8,
							 fgINT16 *pdil, fgINT16 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_9_SIMD(__m128i,8,
						  _mm_cmpeq_epi16,_mm_set1_epi16,
						  _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_9_SIMD(__m64,4,
						  _mm_cmpeq_pi16,_mm_set1_pi16, 
						  _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_9;
#endif
#endif
}









inline void flgr_stop_label_collision_8_connex_6_fgINT32(fgINT32 *pn3, fgINT32 *pn4, fgINT32 *pn5,
							 fgINT32 *pn6, fgINT32 *pn7, fgINT32 *pn8,
							 fgINT32 *pdil, fgINT32 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_6_SIMD(__m128i,4,
						  _mm_cmpeq_epi32,_mm_set1_epi32,
						  _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_6_SIMD(__m64,2,
						  _mm_cmpeq_pi32,_mm_set1_pi32, 
						  _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_6;
#endif
#endif
}


inline void flgr_stop_label_collision_8_connex_9_fgINT32(fgINT32 *pn0, fgINT32 *pn1, fgINT32 *pn2,
							 fgINT32 *pn3, fgINT32 *pn4, fgINT32 *pn5,
							 fgINT32 *pn6, fgINT32 *pn7, fgINT32 *pn8,
							 fgINT32 *pdil, fgINT32 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_9_SIMD(__m128i,4,
						  _mm_cmpeq_epi32,_mm_set1_epi32,
						  _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_9_SIMD(__m64,2,
						  _mm_cmpeq_pi32,_mm_set1_pi32, 
						  _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_9;
#endif
#endif
}








inline void flgr_stop_label_collision_8_connex_6_fgFLOAT32(fgFLOAT32 *pn3, fgFLOAT32 *pn4, fgFLOAT32 *pn5,
							   fgFLOAT32 *pn6, fgFLOAT32 *pn7, fgFLOAT32 *pn8,
							   fgFLOAT32 *pdil, fgFLOAT32 *pcenter, int length) {
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_6;
}


inline void flgr_stop_label_collision_8_connex_9_fgFLOAT32(fgFLOAT32 *pn0, fgFLOAT32 *pn1, fgFLOAT32 *pn2,
							   fgFLOAT32 *pn3, fgFLOAT32 *pn4, fgFLOAT32 *pn5,
							   fgFLOAT32 *pn6, fgFLOAT32 *pn7, fgFLOAT32 *pn8,
							   fgFLOAT32 *pdil, fgFLOAT32 *pcenter, int length) {
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_9;
}









inline void flgr_stop_label_collision_8_connex_6_fgFLOAT64(fgFLOAT64 *pn3, fgFLOAT64 *pn4, fgFLOAT64 *pn5,
							   fgFLOAT64 *pn6, fgFLOAT64 *pn7, fgFLOAT64 *pn8,
							   fgFLOAT64 *pdil, fgFLOAT64 *pcenter, int length) {
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_6;
}


inline void flgr_stop_label_collision_8_connex_9_fgFLOAT64(fgFLOAT64 *pn0, fgFLOAT64 *pn1, fgFLOAT64 *pn2,
							   fgFLOAT64 *pn3, fgFLOAT64 *pn4, fgFLOAT64 *pn5,
							   fgFLOAT64 *pn6, fgFLOAT64 *pn7, fgFLOAT64 *pn8,
							   fgFLOAT64 *pdil, fgFLOAT64 *pcenter, int length) {
  FLGR_MACRO_STOP_LABEL_COLLISION_8_CONNEX_9;
}

























/*  STRUCTURING ELEMENT
 *        EVEN           ODD
 *    P1  . 1 2    P2   0 1 .
 *        3 4 5         3 4 5
 *        . 7 8         6 7 .
 *
 */




#define FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_6			\
  int i;								\
									\
  for(i=0 ; i<length ; i++) {						\
    if(pcenter[i] != pdil[i] ) {					\
      if((pn3[i] != 0) && (pn3[i] != pdil[i]) && (i!=0)) {		\
	pdil[i] = 0; continue;						\
      }									\
      if((pn4[i] != 0) && (pn4[i] != pdil[i])) {			\
	pdil[i] = 0; continue;						\
      }									\
      if((pn5[i] != 0) && (pn5[i] != pdil[i]) && (i!=length-1)) {	\
	pdil[i] = 0; continue;						\
      }									\
      if((pn7[i] != 0) && (pn7[i] != pdil[i])) {			\
	pdil[i] = 0; continue;						\
      }									\
      if((pn8[i] != 0) && (pn8[i] != pdil[i]) && (i!=length-1)) {	\
	pdil[i] = 0; continue;						\
      }									\
    }									\
  }									\
  ;



#define FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_9			\
  int i;								\
									\
  for(i=0 ; i<length ; i++) {						\
    if(pcenter[i] != pdil[i] ) {					\
      if((pn1[i] != 0) && (pn1[i] != pdil[i])) {			\
	pdil[i] = 0; continue;						\
      }									\
      if((pn2[i] != 0) && (pn2[i] != pdil[i]) && (i!=length-1)) {	\
	pdil[i] = 0; continue;						\
      }									\
      if((pn3[i] != 0) && (pn3[i] != pdil[i]) && (i!=0)) {		\
	pdil[i] = 0; continue;						\
      }									\
      if((pn4[i] != 0) && (pn4[i] != pdil[i])) {			\
	pdil[i] = 0; continue;						\
      }									\
      if((pn5[i] != 0) && (pn5[i] != pdil[i]) && (i!=length-1)) {	\
	pdil[i] = 0; continue;						\
      }									\
      if((pn7[i] != 0) && (pn7[i] != pdil[i])) {			\
	pdil[i] = 0; continue;						\
      }									\
      if((pn8[i] != 0) && (pn8[i] != pdil[i]) && (i!=length-1)) {	\
	pdil[i] = 0; continue;						\
      }									\
    }									\
  }									\
  ;




#define FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_6_SIMD(vtype,vsize,	\
							   cmp_instr,set1_instr, \
							   and_instr,or_instr) \
  int i;								\
  vtype vec_pnx;							\
  vtype vec_center;							\
  vtype vec_dil;							\
  vtype vec_cmp1;							\
  vtype vec_cmp2;							\
  vtype vec_zero = set1_instr(0);					\
									\
  *pdil = rep_dil(pcenter,pdil,pn4);					\
  *pdil = rep_dil(pcenter,pdil,pn5);					\
  *pdil = rep_dil(pcenter,pdil,pn7);					\
  *pdil = rep_dil(pcenter,pdil,pn8);					\
									\
  pcenter++;								\
  pdil++;								\
  pn3++;								\
  pn4++;								\
  pn5++;								\
  pn7++;								\
  pn8++;								\
									\
  for(i=1 ; i<vsize ; i++) {						\
    *pdil = rep_dil(pcenter,pdil,pn3);					\
    *pdil = rep_dil(pcenter,pdil,pn4);					\
    *pdil = rep_dil(pcenter,pdil,pn5);					\
    *pdil = rep_dil(pcenter,pdil,pn7);					\
    *pdil = rep_dil(pcenter,pdil,pn8);					\
    pdil++;								\
    pcenter++;								\
    pn3++;								\
    pn4++;								\
    pn5++;								\
    pn7++;								\
    pn8++;								\
  }	 								\
									\
  for(i=vsize ; i<length-vsize ; i+=vsize) {				\
    vec_center = *((vtype*) pcenter);					\
    vec_dil  = *((vtype*) pdil);					\
    vec_cmp1 = cmp_instr(vec_center,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn3);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn4);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn5);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn7);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn8);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    *((vtype*) pdil)=vec_dil;						\
									\
    pcenter += vsize;							\
    pdil += vsize;							\
    pn3 += vsize;							\
    pn4 += vsize;							\
    pn5 += vsize;							\
    pn7 += vsize;							\
    pn8 += vsize;							\
  }									\
  									\
  for( ; i<length-1 ; i++) {						\
    *pdil = rep_dil(pcenter,pdil,pn3);					\
    *pdil = rep_dil(pcenter,pdil,pn4);					\
    *pdil = rep_dil(pcenter,pdil,pn5);					\
    *pdil = rep_dil(pcenter,pdil,pn7);					\
    *pdil = rep_dil(pcenter,pdil,pn8);					\
    pdil++;								\
    pcenter++;								\
    pn3++;								\
    pn4++;								\
    pn5++;								\
    pn7++;								\
    pn8++;								\
  }	 								\
									\
  *pdil = rep_dil(pcenter,pdil,pn3);					\
  *pdil = rep_dil(pcenter,pdil,pn4);					\
  *pdil = rep_dil(pcenter,pdil,pn7)


#define FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_9_SIMD(vtype,vsize,	\
							   cmp_instr,set1_instr, \
							   and_instr,or_instr) \
  int i;								\
  vtype vec_pnx;							\
  vtype vec_center;							\
  vtype vec_dil;							\
  vtype vec_cmp1;							\
  vtype vec_cmp2;							\
  vtype vec_zero = set1_instr(0);					\
									\
  *pdil = rep_dil(pcenter,pdil,pn1);					\
  *pdil = rep_dil(pcenter,pdil,pn2);					\
  *pdil = rep_dil(pcenter,pdil,pn4);					\
  *pdil = rep_dil(pcenter,pdil,pn5);					\
  *pdil = rep_dil(pcenter,pdil,pn7);					\
  *pdil = rep_dil(pcenter,pdil,pn8);					\
									\
  pcenter++;								\
  pdil++;								\
  pn1++;								\
  pn2++;								\
  pn3++;								\
  pn4++;								\
  pn5++;								\
  pn7++;								\
  pn8++;								\
									\
  for(i=1 ; i<vsize ; i++) {						\
    *pdil = rep_dil(pcenter,pdil,pn1);					\
    *pdil = rep_dil(pcenter,pdil,pn2);					\
    *pdil = rep_dil(pcenter,pdil,pn3);					\
    *pdil = rep_dil(pcenter,pdil,pn4);					\
    *pdil = rep_dil(pcenter,pdil,pn5);					\
    *pdil = rep_dil(pcenter,pdil,pn7);					\
    *pdil = rep_dil(pcenter,pdil,pn8);					\
    pdil++;								\
    pcenter++;								\
    pn1++;								\
    pn2++;								\
    pn3++;								\
    pn4++;								\
    pn5++;								\
    pn7++;								\
    pn8++;								\
  }	 								\
									\
  for(i=vsize ; i<length-vsize ; i+=vsize) {				\
    vec_center = *((vtype*) pcenter);					\
    vec_dil  = *((vtype*) pdil);					\
    vec_cmp1 = cmp_instr(vec_center,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn1);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn2);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn3);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn4);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn5);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn7);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn8);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    *((vtype*) pdil) = vec_dil;						\
									\
    pcenter += vsize;							\
    pdil += vsize;							\
    pn1 += vsize;							\
    pn2 += vsize;							\
    pn3 += vsize;							\
    pn4 += vsize;							\
    pn5 += vsize;							\
    pn7 += vsize;							\
    pn8 += vsize;							\
  }									\
									\
  for( ; i<length-1 ; i++) {						\
    *pdil = rep_dil(pcenter,pdil,pn1);					\
    *pdil = rep_dil(pcenter,pdil,pn2);					\
    *pdil = rep_dil(pcenter,pdil,pn3);					\
    *pdil = rep_dil(pcenter,pdil,pn4);					\
    *pdil = rep_dil(pcenter,pdil,pn5);					\
    *pdil = rep_dil(pcenter,pdil,pn7);					\
    *pdil = rep_dil(pcenter,pdil,pn8);					\
    pdil++;								\
    pcenter++;								\
    pn1++;								\
    pn2++;								\
    pn3++;								\
    pn4++;								\
    pn5++;								\
    pn7++;								\
    pn8++;								\
  }	 								\
									\
  *pdil = rep_dil(pcenter,pdil,pn1);					\
  *pdil = rep_dil(pcenter,pdil,pn3);					\
  *pdil = rep_dil(pcenter,pdil,pn4);					\
  *pdil = rep_dil(pcenter,pdil,pn7)


			  







inline void flgr_stop_label_collision_6_connex_p1_6_fgUINT8(fgUINT8 *pn3, fgUINT8 *pn4, fgUINT8 *pn5,
							    fgUINT8 *pn7, fgUINT8 *pn8,
							    fgUINT8 *pdil, fgUINT8 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_6_SIMD(__m128i,16,
						     _mm_cmpeq_epi8,_mm_set1_epi8, 
						     _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_6_SIMD(__m64,8,
						     _mm_cmpeq_pi8,_mm_set1_pi8, 
						     _mm_and_si64,_mm_or_si64);
  _mm_empty();
#else
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_6;
#endif
#endif
}


inline void flgr_stop_label_collision_6_connex_p1_9_fgUINT8(fgUINT8 *pn1, fgUINT8 *pn2,
							    fgUINT8 *pn3, fgUINT8 *pn4, fgUINT8 *pn5,
							    fgUINT8 *pn7, fgUINT8 *pn8,
							    fgUINT8 *pdil, fgUINT8 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_9_SIMD(__m128i,16,
						     _mm_cmpeq_epi8,_mm_set1_epi8,
						     _mm_and_si128,_mm_or_si128);

#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_9_SIMD(__m64,8,
						     _mm_cmpeq_pi8,_mm_set1_pi8, 
						     _mm_and_si64,_mm_or_si64);
  _mm_empty();
#else
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_9;
#endif
#endif
}










inline void flgr_stop_label_collision_6_connex_p1_6_fgUINT16(fgUINT16 *pn3, fgUINT16 *pn4, fgUINT16 *pn5,
							     fgUINT16 *pn7, fgUINT16 *pn8,
							     fgUINT16 *pdil, fgUINT16 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_6_SIMD(__m128i,8,
						     _mm_cmpeq_epi16,_mm_set1_epi16,
						     _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_6_SIMD(__m64,4,
						     _mm_cmpeq_pi16,_mm_set1_pi16, 
						     _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_6;
#endif
#endif
}


inline void flgr_stop_label_collision_6_connex_p1_9_fgUINT16(fgUINT16 *pn1, fgUINT16 *pn2,
							     fgUINT16 *pn3, fgUINT16 *pn4, fgUINT16 *pn5,
							     fgUINT16 *pn7, fgUINT16 *pn8,
							     fgUINT16 *pdil, fgUINT16 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_9_SIMD(__m128i,8,
						     _mm_cmpeq_epi16,_mm_set1_epi16,
						     _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_9_SIMD(__m64,4,
						     _mm_cmpeq_pi16,_mm_set1_pi16, 
						     _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_9;
#endif
#endif
}









inline void flgr_stop_label_collision_6_connex_p1_6_fgUINT32(fgUINT32 *pn3, fgUINT32 *pn4, fgUINT32 *pn5,
							     fgUINT32 *pn7, fgUINT32 *pn8,
							     fgUINT32 *pdil, fgUINT32 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_6_SIMD(__m128i,4,
						     _mm_cmpeq_epi32,_mm_set1_epi32,
						     _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_6_SIMD(__m64,2,
						     _mm_cmpeq_pi32,_mm_set1_pi32, 
						     _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_6;
#endif
#endif
}


inline void flgr_stop_label_collision_6_connex_p1_9_fgUINT32(fgUINT32 *pn1, fgUINT32 *pn2,
							     fgUINT32 *pn3, fgUINT32 *pn4, fgUINT32 *pn5,
							     fgUINT32 *pn7, fgUINT32 *pn8,
							     fgUINT32 *pdil, fgUINT32 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_9_SIMD(__m128i,4,
						     _mm_cmpeq_epi32,_mm_set1_epi32,
						     _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_9_SIMD(__m64,2,
						     _mm_cmpeq_pi32,_mm_set1_pi32, 
						     _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_9;
#endif
#endif
}




















inline void flgr_stop_label_collision_6_connex_p1_6_fgINT8(fgINT8 *pn3, fgINT8 *pn4, fgINT8 *pn5,
							   fgINT8 *pn7, fgINT8 *pn8,
							   fgINT8 *pdil, fgINT8 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_6_SIMD(__m128i,16,
						     _mm_cmpeq_epi8,_mm_set1_epi8, 
						     _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_6_SIMD(__m64,8,
						     _mm_cmpeq_pi8,_mm_set1_pi8, 
						     _mm_and_si64,_mm_or_si64);
  _mm_empty();
#else
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_6;
#endif
#endif
}


inline void flgr_stop_label_collision_6_connex_p1_9_fgINT8(fgINT8 *pn1, fgINT8 *pn2,
							   fgINT8 *pn3, fgINT8 *pn4, fgINT8 *pn5,
							   fgINT8 *pn7, fgINT8 *pn8,
							   fgINT8 *pdil, fgINT8 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_9_SIMD(__m128i,16,
						     _mm_cmpeq_epi8,_mm_set1_epi8,
						     _mm_and_si128,_mm_or_si128);

#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_9_SIMD(__m64,8,
						     _mm_cmpeq_pi8,_mm_set1_pi8, 
						     _mm_and_si64,_mm_or_si64);
  _mm_empty();
#else
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_9;
#endif
#endif
}










inline void flgr_stop_label_collision_6_connex_p1_6_fgINT16(fgINT16 *pn3, fgINT16 *pn4, fgINT16 *pn5,
							    fgINT16 *pn7, fgINT16 *pn8,
							    fgINT16 *pdil, fgINT16 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_6_SIMD(__m128i,8,
						     _mm_cmpeq_epi16,_mm_set1_epi16,
						     _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_6_SIMD(__m64,4,
						     _mm_cmpeq_pi16,_mm_set1_pi16, 
						     _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_6;
#endif
#endif
}


inline void flgr_stop_label_collision_6_connex_p1_9_fgINT16(fgINT16 *pn1, fgINT16 *pn2,
							    fgINT16 *pn3, fgINT16 *pn4, fgINT16 *pn5,
							    fgINT16 *pn7, fgINT16 *pn8,
							    fgINT16 *pdil, fgINT16 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_9_SIMD(__m128i,8,
						     _mm_cmpeq_epi16,_mm_set1_epi16,
						     _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_9_SIMD(__m64,4,
						     _mm_cmpeq_pi16,_mm_set1_pi16, 
						     _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_9;
#endif
#endif
}









inline void flgr_stop_label_collision_6_connex_p1_6_fgINT32(fgINT32 *pn3, fgINT32 *pn4, fgINT32 *pn5,
							    fgINT32 *pn7, fgINT32 *pn8,
							    fgINT32 *pdil, fgINT32 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_6_SIMD(__m128i,4,
						     _mm_cmpeq_epi32,_mm_set1_epi32,
						     _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_6_SIMD(__m64,2,
						     _mm_cmpeq_pi32,_mm_set1_pi32, 
						     _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_6;
#endif
#endif
}


inline void flgr_stop_label_collision_6_connex_p1_9_fgINT32(fgINT32 *pn1, fgINT32 *pn2,
							    fgINT32 *pn3, fgINT32 *pn4, fgINT32 *pn5,
							    fgINT32 *pn7, fgINT32 *pn8,
							    fgINT32 *pdil, fgINT32 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_9_SIMD(__m128i,4,
						     _mm_cmpeq_epi32,_mm_set1_epi32,
						     _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_9_SIMD(__m64,2,
						     _mm_cmpeq_pi32,_mm_set1_pi32, 
						     _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_9;
#endif
#endif
}








inline void flgr_stop_label_collision_6_connex_p1_6_fgFLOAT32(fgFLOAT32 *pn3, fgFLOAT32 *pn4, fgFLOAT32 *pn5,
							      fgFLOAT32 *pn7, fgFLOAT32 *pn8,
							      fgFLOAT32 *pdil, fgFLOAT32 *pcenter, int length) {
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_6;
}


inline void flgr_stop_label_collision_6_connex_p1_9_fgFLOAT32(fgFLOAT32 *pn1, fgFLOAT32 *pn2,
							      fgFLOAT32 *pn3, fgFLOAT32 *pn4, fgFLOAT32 *pn5,
							      fgFLOAT32 *pn7, fgFLOAT32 *pn8,
							      fgFLOAT32 *pdil, fgFLOAT32 *pcenter, int length) {
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_9;
}









inline void flgr_stop_label_collision_6_connex_p1_6_fgFLOAT64(fgFLOAT64 *pn3, fgFLOAT64 *pn4, fgFLOAT64 *pn5,
							      fgFLOAT64 *pn7, fgFLOAT64 *pn8,
							      fgFLOAT64 *pdil, fgFLOAT64 *pcenter, int length) {
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_6;
}


inline void flgr_stop_label_collision_6_connex_p1_9_fgFLOAT64(fgFLOAT64 *pn1, fgFLOAT64 *pn2,
							      fgFLOAT64 *pn3, fgFLOAT64 *pn4, fgFLOAT64 *pn5,
							      fgFLOAT64 *pn7, fgFLOAT64 *pn8,
							      fgFLOAT64 *pdil, fgFLOAT64 *pcenter, int length) {
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P1_9;
}



























#define FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_6			\
  int i;								\
									\
  for(i=0 ; i<length ; i++) {						\
    if(pcenter[i] != pdil[i] ) {					\
      if((pn3[i] != 0) && (pn3[i] != pdil[i]) && (i!=0)) {		\
	pdil[i] = 0; continue;						\
      }									\
      if((pn4[i] != 0) && (pn4[i] != pdil[i])) {			\
	pdil[i] = 0; continue;						\
      }									\
      if((pn5[i] != 0) && (pn5[i] != pdil[i]) && (i!=length-1)) {	\
	pdil[i] = 0; continue;						\
      }									\
      if((pn6[i] != 0) && (pn6[i] != pdil[i]) && (i!=0)) {		\
	pdil[i] = 0; continue;						\
      }									\
      if((pn7[i] != 0) && (pn7[i] != pdil[i])) {			\
	pdil[i] = 0; continue;						\
      }									\
    }									\
  }									\
  ;



#define FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_9			\
  int i;								\
									\
  for(i=0 ; i<length ; i++) {						\
    if(pcenter[i] != pdil[i] ) {					\
      if((pn0[i] != 0) && (pn0[i] != pdil[i]) && (i!=0)) {		\
	pdil[i] = 0; continue;						\
      }									\
      if((pn1[i] != 0) && (pn1[i] != pdil[i])) {			\
	pdil[i] = 0; continue;						\
      }									\
      if((pn3[i] != 0) && (pn3[i] != pdil[i]) && (i!=0)) {		\
	pdil[i] = 0; continue;						\
      }									\
      if((pn4[i] != 0) && (pn4[i] != pdil[i])) {			\
	pdil[i] = 0; continue;						\
      }									\
      if((pn5[i] != 0) && (pn5[i] != pdil[i]) && (i!=length-1)) {	\
	pdil[i] = 0; continue;						\
      }									\
      if((pn6[i] != 0) && (pn6[i] != pdil[i]) && (i!=0)) {		\
	pdil[i] = 0; continue;						\
      }									\
      if((pn7[i] != 0) && (pn7[i] != pdil[i])) {			\
	pdil[i] = 0; continue;						\
      }									\
    }									\
  }									\
  ;




#define FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_6_SIMD(vtype,vsize,	\
							   cmp_instr,set1_instr, \
							   and_instr,or_instr) \
  int i;								\
  vtype vec_pnx;							\
  vtype vec_center;							\
  vtype vec_dil;							\
  vtype vec_cmp1;							\
  vtype vec_cmp2;							\
  vtype vec_zero = set1_instr(0);					\
									\
  *pdil = rep_dil(pcenter,pdil,pn4);					\
  *pdil = rep_dil(pcenter,pdil,pn5);					\
  *pdil = rep_dil(pcenter,pdil,pn7);					\
									\
  pcenter++;								\
  pdil++;								\
  pn3++;								\
  pn4++;								\
  pn5++;								\
  pn6++;								\
  pn7++;								\
									\
  for(i=1 ; i<vsize ; i++) {						\
    *pdil = rep_dil(pcenter,pdil,pn3);					\
    *pdil = rep_dil(pcenter,pdil,pn4);					\
    *pdil = rep_dil(pcenter,pdil,pn5);					\
    *pdil = rep_dil(pcenter,pdil,pn6);					\
    *pdil = rep_dil(pcenter,pdil,pn7);					\
    pdil++;								\
    pcenter++;								\
    pn3++;								\
    pn4++;								\
    pn5++;								\
    pn6++;								\
    pn7++;								\
  }	 								\
									\
  for(i=vsize ; i<length-vsize ; i+=vsize) {				\
    vec_center = *((vtype*) pcenter);					\
    vec_dil  = *((vtype*) pdil);					\
    vec_cmp1 = cmp_instr(vec_center,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn3);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn4);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn5);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn6);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn7);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    *((vtype*) pdil)=vec_dil;						\
									\
    pcenter += vsize;							\
    pdil += vsize;							\
    pn3 += vsize;							\
    pn4 += vsize;							\
    pn5 += vsize;							\
    pn6 += vsize;							\
    pn7 += vsize;							\
  }									\
  									\
  for( ; i<length-1 ; i++) {						\
    *pdil = rep_dil(pcenter,pdil,pn3);					\
    *pdil = rep_dil(pcenter,pdil,pn4);					\
    *pdil = rep_dil(pcenter,pdil,pn5);					\
    *pdil = rep_dil(pcenter,pdil,pn6);					\
    *pdil = rep_dil(pcenter,pdil,pn7);					\
    pdil++;								\
    pcenter++;								\
    pn3++;								\
    pn4++;								\
    pn5++;								\
    pn6++;								\
    pn7++;								\
  }	 								\
									\
  *pdil = rep_dil(pcenter,pdil,pn3);					\
  *pdil = rep_dil(pcenter,pdil,pn4);					\
  *pdil = rep_dil(pcenter,pdil,pn6);					\
  *pdil = rep_dil(pcenter,pdil,pn7)


#define FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_9_SIMD(vtype,vsize,	\
							   cmp_instr,set1_instr, \
							   and_instr,or_instr) \
  int i;								\
  vtype vec_pnx;							\
  vtype vec_center;							\
  vtype vec_dil;							\
  vtype vec_cmp1;							\
  vtype vec_cmp2;							\
  vtype vec_zero = set1_instr(0);					\
									\
  *pdil = rep_dil(pcenter,pdil,pn1);					\
  *pdil = rep_dil(pcenter,pdil,pn4);					\
  *pdil = rep_dil(pcenter,pdil,pn5);					\
  *pdil = rep_dil(pcenter,pdil,pn7);					\
									\
  pcenter++;								\
  pdil++;								\
  pn0++;								\
  pn1++;								\
  pn3++;								\
  pn4++;								\
  pn5++;								\
  pn6++;								\
  pn7++;								\
									\
  for(i=1 ; i<vsize ; i++) {						\
    *pdil = rep_dil(pcenter,pdil,pn0);					\
    *pdil = rep_dil(pcenter,pdil,pn1);					\
    *pdil = rep_dil(pcenter,pdil,pn3);					\
    *pdil = rep_dil(pcenter,pdil,pn4);					\
    *pdil = rep_dil(pcenter,pdil,pn5);					\
    *pdil = rep_dil(pcenter,pdil,pn6);					\
    *pdil = rep_dil(pcenter,pdil,pn7);					\
    pdil++;								\
    pcenter++;								\
    pn0++;								\
    pn1++;								\
    pn3++;								\
    pn4++;								\
    pn5++;								\
    pn6++;								\
    pn7++;								\
  }	 								\
									\
  for(i=vsize ; i<length-vsize ; i+=vsize) {				\
    vec_center = *((vtype*) pcenter);					\
    vec_dil  = *((vtype*) pdil);					\
    vec_cmp1 = cmp_instr(vec_center,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn0);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn1);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn3);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn4);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn5);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn6);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn7);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    *((vtype*) pdil) = vec_dil;						\
									\
    pcenter += vsize;							\
    pdil += vsize;							\
    pn0 += vsize;							\
    pn1 += vsize;							\
    pn3 += vsize;							\
    pn4 += vsize;							\
    pn5 += vsize;							\
    pn6 += vsize;							\
    pn7 += vsize;							\
  }									\
									\
  for( ; i<length-1 ; i++) {						\
    *pdil = rep_dil(pcenter,pdil,pn0);					\
    *pdil = rep_dil(pcenter,pdil,pn1);					\
    *pdil = rep_dil(pcenter,pdil,pn3);					\
    *pdil = rep_dil(pcenter,pdil,pn4);					\
    *pdil = rep_dil(pcenter,pdil,pn5);					\
    *pdil = rep_dil(pcenter,pdil,pn6);					\
    *pdil = rep_dil(pcenter,pdil,pn7);					\
    pdil++;								\
    pcenter++;								\
    pn0++;								\
    pn1++;								\
    pn3++;								\
    pn4++;								\
    pn5++;								\
    pn6++;								\
    pn7++;								\
  }	 								\
									\
  *pdil = rep_dil(pcenter,pdil,pn0);					\
  *pdil = rep_dil(pcenter,pdil,pn1);					\
  *pdil = rep_dil(pcenter,pdil,pn3);					\
  *pdil = rep_dil(pcenter,pdil,pn4);					\
  *pdil = rep_dil(pcenter,pdil,pn6);					\
  *pdil = rep_dil(pcenter,pdil,pn7)


			  







inline void flgr_stop_label_collision_6_connex_p2_6_fgUINT8(fgUINT8 *pn3, fgUINT8 *pn4, fgUINT8 *pn5,
							    fgUINT8 *pn6, fgUINT8 *pn7, 
							    fgUINT8 *pdil, fgUINT8 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_6_SIMD(__m128i,16,_mm_cmpeq_epi8,_mm_set1_epi8, 
						     _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_6_SIMD(__m64,8,
						     _mm_cmpeq_pi8,_mm_set1_pi8, 
						     _mm_and_si64,_mm_or_si64);
  _mm_empty();
#else
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_6;
#endif
#endif
}


inline void flgr_stop_label_collision_6_connex_p2_9_fgUINT8(fgUINT8 *pn0, fgUINT8 *pn1, 
							    fgUINT8 *pn3, fgUINT8 *pn4, fgUINT8 *pn5,
							    fgUINT8 *pn6, fgUINT8 *pn7, 
							    fgUINT8 *pdil, fgUINT8 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_9_SIMD(__m128i,16,_mm_cmpeq_epi8,_mm_set1_epi8,
						     _mm_and_si128,_mm_or_si128);

#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_9_SIMD(__m64,8,
						     _mm_cmpeq_pi8,_mm_set1_pi8, 
						     _mm_and_si64,_mm_or_si64);
  _mm_empty();
#else
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_9;
#endif
#endif
}










inline void flgr_stop_label_collision_6_connex_p2_6_fgUINT16(fgUINT16 *pn3, fgUINT16 *pn4, fgUINT16 *pn5,
							     fgUINT16 *pn6, fgUINT16 *pn7, 
							     fgUINT16 *pdil, fgUINT16 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_6_SIMD(__m128i,8,_mm_cmpeq_epi16,_mm_set1_epi16,
						     _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_6_SIMD(__m64,4,
						     _mm_cmpeq_pi16,_mm_set1_pi16, 
						     _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_6;
#endif
#endif
}


inline void flgr_stop_label_collision_6_connex_p2_9_fgUINT16(fgUINT16 *pn0, fgUINT16 *pn1, 
							     fgUINT16 *pn3, fgUINT16 *pn4, fgUINT16 *pn5,
							     fgUINT16 *pn6, fgUINT16 *pn7, 
							     fgUINT16 *pdil, fgUINT16 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_9_SIMD(__m128i,8,_mm_cmpeq_epi16,_mm_set1_epi16,
						     _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_9_SIMD(__m64,4,
						     _mm_cmpeq_pi16,_mm_set1_pi16, 
						     _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_9;
#endif
#endif
}









inline void flgr_stop_label_collision_6_connex_p2_6_fgUINT32(fgUINT32 *pn3, fgUINT32 *pn4, fgUINT32 *pn5,
							     fgUINT32 *pn6, fgUINT32 *pn7, 
							     fgUINT32 *pdil, fgUINT32 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_6_SIMD(__m128i,4,_mm_cmpeq_epi32,_mm_set1_epi32,
						     _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_6_SIMD(__m64,2,
						     _mm_cmpeq_pi32,_mm_set1_pi32, 
						     _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_6;
#endif
#endif
}


inline void flgr_stop_label_collision_6_connex_p2_9_fgUINT32(fgUINT32 *pn0, fgUINT32 *pn1, 
							     fgUINT32 *pn3, fgUINT32 *pn4, fgUINT32 *pn5,
							     fgUINT32 *pn6, fgUINT32 *pn7, 
							     fgUINT32 *pdil, fgUINT32 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_9_SIMD(__m128i,4,_mm_cmpeq_epi32,_mm_set1_epi32,
						     _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_9_SIMD(__m64,2,
						     _mm_cmpeq_pi32,_mm_set1_pi32, 
						     _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_9;
#endif
#endif
}




















inline void flgr_stop_label_collision_6_connex_p2_6_fgINT8(fgINT8 *pn3, fgINT8 *pn4, fgINT8 *pn5,
							   fgINT8 *pn6, fgINT8 *pn7, 
							   fgINT8 *pdil, fgINT8 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_6_SIMD(__m128i,16,_mm_cmpeq_epi8,_mm_set1_epi8, 
						     _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_6_SIMD(__m64,8,
						     _mm_cmpeq_pi8,_mm_set1_pi8, 
						     _mm_and_si64,_mm_or_si64);
  _mm_empty();
#else
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_6;
#endif
#endif
}


inline void flgr_stop_label_collision_6_connex_p2_9_fgINT8(fgINT8 *pn0, fgINT8 *pn1, 
							   fgINT8 *pn3, fgINT8 *pn4, fgINT8 *pn5,
							   fgINT8 *pn6, fgINT8 *pn7, 
							   fgINT8 *pdil, fgINT8 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_9_SIMD(__m128i,16,_mm_cmpeq_epi8,_mm_set1_epi8,
						     _mm_and_si128,_mm_or_si128);

#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_9_SIMD(__m64,8,
						     _mm_cmpeq_pi8,_mm_set1_pi8, 
						     _mm_and_si64,_mm_or_si64);
  _mm_empty();
#else
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_9;
#endif
#endif
}










inline void flgr_stop_label_collision_6_connex_p2_6_fgINT16(fgINT16 *pn3, fgINT16 *pn4, fgINT16 *pn5,
							    fgINT16 *pn6, fgINT16 *pn7, 
							    fgINT16 *pdil, fgINT16 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_6_SIMD(__m128i,8,_mm_cmpeq_epi16,_mm_set1_epi16,
						     _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_6_SIMD(__m64,4,
						     _mm_cmpeq_pi16,_mm_set1_pi16, 
						     _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_6;
#endif
#endif
}


inline void flgr_stop_label_collision_6_connex_p2_9_fgINT16(fgINT16 *pn0, fgINT16 *pn1, 
							    fgINT16 *pn3, fgINT16 *pn4, fgINT16 *pn5,
							    fgINT16 *pn6, fgINT16 *pn7, 
							    fgINT16 *pdil, fgINT16 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_9_SIMD(__m128i,8,_mm_cmpeq_epi16,_mm_set1_epi16,
						     _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_9_SIMD(__m64,4,
						     _mm_cmpeq_pi16,_mm_set1_pi16, 
						     _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_9;
#endif
#endif
}









inline void flgr_stop_label_collision_6_connex_p2_6_fgINT32(fgINT32 *pn3, fgINT32 *pn4, fgINT32 *pn5,
							    fgINT32 *pn6, fgINT32 *pn7, 
							    fgINT32 *pdil, fgINT32 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_6_SIMD(__m128i,4,_mm_cmpeq_epi32,_mm_set1_epi32,
						     _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_6_SIMD(__m64,2,
						     _mm_cmpeq_pi32,_mm_set1_pi32, 
						     _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_6;
#endif
#endif
}


inline void flgr_stop_label_collision_6_connex_p2_9_fgINT32(fgINT32 *pn0, fgINT32 *pn1, 
							    fgINT32 *pn3, fgINT32 *pn4, fgINT32 *pn5,
							    fgINT32 *pn6, fgINT32 *pn7, 
							    fgINT32 *pdil, fgINT32 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_9_SIMD(__m128i,4,_mm_cmpeq_epi32,_mm_set1_epi32,
						     _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_9_SIMD(__m64,2,
						    _mm_cmpeq_pi32,_mm_set1_pi32, 
						    _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_9;
#endif
#endif
}








inline void flgr_stop_label_collision_6_connex_p2_6_fgFLOAT32(fgFLOAT32 *pn3, fgFLOAT32 *pn4, fgFLOAT32 *pn5,
							      fgFLOAT32 *pn6, fgFLOAT32 *pn7, 
							      fgFLOAT32 *pdil, fgFLOAT32 *pcenter, int length) {
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_6;
}


inline void flgr_stop_label_collision_6_connex_p2_9_fgFLOAT32(fgFLOAT32 *pn0, fgFLOAT32 *pn1, 
							      fgFLOAT32 *pn3, fgFLOAT32 *pn4, fgFLOAT32 *pn5,
							      fgFLOAT32 *pn6, fgFLOAT32 *pn7, 
							      fgFLOAT32 *pdil, fgFLOAT32 *pcenter, int length) {
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_9;
}









inline void flgr_stop_label_collision_6_connex_p2_6_fgFLOAT64(fgFLOAT64 *pn3, fgFLOAT64 *pn4, fgFLOAT64 *pn5,
							      fgFLOAT64 *pn6, fgFLOAT64 *pn7, 
							      fgFLOAT64 *pdil, fgFLOAT64 *pcenter, int length) {
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_6;
}


inline void flgr_stop_label_collision_6_connex_p2_9_fgFLOAT64(fgFLOAT64 *pn0, fgFLOAT64 *pn1, 
							      fgFLOAT64 *pn3, fgFLOAT64 *pn4, fgFLOAT64 *pn5,
							      fgFLOAT64 *pn6, fgFLOAT64 *pn7, 
							      fgFLOAT64 *pdil, fgFLOAT64 *pcenter, int length) {
  FLGR_MACRO_STOP_LABEL_COLLISION_6_CONNEX_P2_9;
}























#define FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_6			\
  int i;								\
									\
  for(i=0 ; i<length ; i++) {						\
    if(pcenter[i] != pdil[i] ) {					\
      if((pn1[i] != 0) && (pn1[i] != pdil[i]) && (i!=0)) {		\
	pdil[i] = 0; continue;						\
      }									\
      if((pn2[i] != 0) && (pn2[i] != pdil[i])) {			\
	pdil[i] = 0; continue;						\
      }									\
      if((pn3[i] != 0) && (pn3[i] != pdil[i]) && (i!=length-1)) {	\
	pdil[i] = 0; continue;						\
      }									\
      if((pn4[i] != 0) && (pn4[i] != pdil[i])) {			\
	pdil[i] = 0; continue;						\
      }									\
    }									\
  }									\
  ;



#define FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_9			\
  int i;								\
									\
  for(i=0 ; i<length ; i++) {						\
    if(pcenter[i] != pdil[i] ) {					\
      if((pn0[i] != 0) && (pn0[i] != pdil[i])) {			\
	pdil[i] = 0; continue;						\
      }									\
      if((pn1[i] != 0) && (pn1[i] != pdil[i]) && (i!=0)) {		\
	pdil[i] = 0; continue;						\
      }									\
      if((pn2[i] != 0) && (pn2[i] != pdil[i])) {			\
	pdil[i] = 0; continue;						\
      }									\
      if((pn3[i] != 0) && (pn3[i] != pdil[i])  && (i!=length-1)) {	\
	pdil[i] = 0; continue;						\
      }									\
      if((pn4[i] != 0) && (pn4[i] != pdil[i])) {			\
	pdil[i] = 0; continue;						\
      }									\
    }									\
  }									\
  ;















#define FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_6_SIMD(vtype,vsize,	\
							cmp_instr,set1_instr, \
							and_instr,or_instr) \
  int i;								\
  vtype vec_pnx;							\
  vtype vec_center;							\
  vtype vec_dil;							\
  vtype vec_cmp1;							\
  vtype vec_cmp2;							\
  vtype vec_zero = set1_instr(0);					\
									\
  *pdil = rep_dil(pcenter,pdil,pn2);					\
  *pdil = rep_dil(pcenter,pdil,pn3);					\
  *pdil = rep_dil(pcenter,pdil,pn4);					\
									\
  pcenter++;								\
  pdil++;								\
  pn1++;								\
  pn2++;								\
  pn3++;								\
  pn4++;								\
									\
  for(i=1 ; i<vsize ; i++) {						\
    *pdil = rep_dil(pcenter,pdil,pn1);					\
    *pdil = rep_dil(pcenter,pdil,pn2);					\
    *pdil = rep_dil(pcenter,pdil,pn3);					\
    *pdil = rep_dil(pcenter,pdil,pn4);					\
    pdil++;								\
    pcenter++;								\
    pn1++;								\
    pn2++;								\
    pn3++;								\
    pn4++;								\
  }	 								\
									\
  for(i=vsize ; i<length-vsize ; i+=vsize) {				\
    vec_center = *((vtype*) pcenter);					\
    vec_dil  = *((vtype*) pdil);					\
    vec_cmp1 = cmp_instr(vec_center,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn1);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn2);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn3);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn4);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    *((vtype*) pdil)=vec_dil;						\
									\
    pcenter += vsize;							\
    pdil += vsize;							\
    pn1 += vsize;							\
    pn2 += vsize;							\
    pn3 += vsize;							\
    pn4 += vsize;							\
  }									\
  									\
  for(i=1 ; i<vsize ; i++) {						\
    *pdil = rep_dil(pcenter,pdil,pn1);					\
    *pdil = rep_dil(pcenter,pdil,pn2);					\
    *pdil = rep_dil(pcenter,pdil,pn3);					\
    *pdil = rep_dil(pcenter,pdil,pn4);					\
    pdil++;								\
    pcenter++;								\
    pn1++;								\
    pn2++;								\
    pn3++;								\
    pn4++;								\
  }	 								\
									\
  *pdil = rep_dil(pcenter,pdil,pn1);					\
  *pdil = rep_dil(pcenter,pdil,pn2);					\
  *pdil = rep_dil(pcenter,pdil,pn4)



#define FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_9_SIMD(vtype,vsize,	\
							cmp_instr,set1_instr, \
							and_instr,or_instr) \
  int i;								\
  vtype vec_pnx;							\
  vtype vec_center;							\
  vtype vec_dil;							\
  vtype vec_cmp1;							\
  vtype vec_cmp2;							\
  vtype vec_zero = set1_instr(0);					\
									\
  *pdil = rep_dil(pcenter,pdil,pn0);					\
  *pdil = rep_dil(pcenter,pdil,pn2);					\
  *pdil = rep_dil(pcenter,pdil,pn3);					\
  *pdil = rep_dil(pcenter,pdil,pn4);					\
									\
  pcenter++;								\
  pdil++;								\
  pn0++;								\
  pn1++;								\
  pn2++;								\
  pn3++;								\
  pn4++;								\
									\
  for(i=1 ; i<vsize ; i++) {						\
    *pdil = rep_dil(pcenter,pdil,pn0);					\
    *pdil = rep_dil(pcenter,pdil,pn1);					\
    *pdil = rep_dil(pcenter,pdil,pn2);					\
    *pdil = rep_dil(pcenter,pdil,pn3);					\
    *pdil = rep_dil(pcenter,pdil,pn4);					\
    pdil++;								\
    pcenter++;								\
    pn0++;								\
    pn1++;								\
    pn2++;								\
    pn3++;								\
    pn4++;								\
  }	 								\
									\
    									\
  for(i=vsize ; i<length-vsize ; i+=vsize) {				\
    vec_center = *((vtype*) pcenter);					\
    vec_dil  = *((vtype*) pdil);					\
    vec_cmp1 = cmp_instr(vec_center,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn0);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn1);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn2);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn3);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    vec_pnx  = *((vtype*) pn4);						\
    vec_cmp2 = cmp_instr(vec_pnx,vec_zero);				\
    vec_pnx  = cmp_instr(vec_pnx,vec_dil);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp2);				\
    vec_pnx  = or_instr(vec_pnx,vec_cmp1);				\
    vec_dil  = and_instr(vec_pnx,vec_dil);				\
									\
    *((vtype*) pdil) = vec_dil;						\
									\
    pcenter += vsize;							\
    pdil += vsize;							\
    pn0 += vsize;							\
    pn1 += vsize;							\
    pn2 += vsize;							\
    pn3 += vsize;							\
    pn4 += vsize;							\
  }									\
									\
  for(i=1 ; i<vsize ; i++) {						\
    *pdil = rep_dil(pcenter,pdil,pn0);					\
    *pdil = rep_dil(pcenter,pdil,pn1);					\
    *pdil = rep_dil(pcenter,pdil,pn2);					\
    *pdil = rep_dil(pcenter,pdil,pn3);					\
    *pdil = rep_dil(pcenter,pdil,pn4);					\
    pdil++;								\
    pcenter++;								\
    pn0++;								\
    pn1++;								\
    pn2++;								\
    pn3++;								\
    pn4++;								\
  }	 								\
									\
  *pdil = rep_dil(pcenter,pdil,pn0);					\
  *pdil = rep_dil(pcenter,pdil,pn1);					\
  *pdil = rep_dil(pcenter,pdil,pn2);					\
  *pdil = rep_dil(pcenter,pdil,pn4)














inline void flgr_stop_label_collision_4_connex_6_fgUINT8(fgUINT8 *pn1,fgUINT8 *pn2, fgUINT8 *pn3,
							 fgUINT8 *pn4,
							 fgUINT8 *pdil, fgUINT8 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_6_SIMD(__m128i,16,
						  _mm_cmpeq_epi8,_mm_set1_epi8, 
						  _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_6_SIMD(__m64,8,
						 _mm_cmpeq_pi8,_mm_set1_pi8, 
						 _mm_and_si64,_mm_or_si64);
  _mm_empty();
#else
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_6;
#endif
#endif
}


inline void flgr_stop_label_collision_4_connex_9_fgUINT8(fgUINT8 *pn0, 
							 fgUINT8 *pn1, fgUINT8 *pn2, fgUINT8 *pn3, 
							 fgUINT8 *pn4, 
							 fgUINT8 *pdil, fgUINT8 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_9_SIMD(__m128i,16,
						  _mm_cmpeq_epi8,_mm_set1_epi8,
						  _mm_and_si128,_mm_or_si128);

#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_9_SIMD(__m64,8,
						 _mm_cmpeq_pi8,_mm_set1_pi8, 
						 _mm_and_si64,_mm_or_si64);
  _mm_empty();
#else
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_9;
#endif
#endif
}










inline void flgr_stop_label_collision_4_connex_6_fgUINT16(fgUINT16 *pn1,fgUINT16 *pn2, fgUINT16 *pn3,
							  fgUINT16 *pn4,
							  fgUINT16 *pdil, fgUINT16 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_6_SIMD(__m128i,8,
						  _mm_cmpeq_epi16,_mm_set1_epi16,
						  _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_6_SIMD(__m64,4,
						 _mm_cmpeq_pi16,_mm_set1_pi16, 
						 _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_6;
#endif
#endif
}


inline void flgr_stop_label_collision_4_connex_9_fgUINT16(fgUINT16 *pn0, 
							  fgUINT16 *pn1, fgUINT16 *pn2, fgUINT16 *pn3, 
							  fgUINT16 *pn4, 
							  fgUINT16 *pdil, fgUINT16 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_9_SIMD(__m128i,8,
						  _mm_cmpeq_epi16,_mm_set1_epi16,
						  _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_9_SIMD(__m64,4,
						 _mm_cmpeq_pi16,_mm_set1_pi16, 
						 _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_9;
#endif
#endif
}









inline void flgr_stop_label_collision_4_connex_6_fgUINT32(fgUINT32 *pn1,fgUINT32 *pn2, fgUINT32 *pn3,
							  fgUINT32 *pn4,
							  fgUINT32 *pdil, fgUINT32 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_6_SIMD(__m128i,4,
						  _mm_cmpeq_epi32,_mm_set1_epi32,
						  _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_6_SIMD(__m64,2,
						 _mm_cmpeq_pi32,_mm_set1_pi32, 
						 _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_6;
#endif
#endif
}


inline void flgr_stop_label_collision_4_connex_9_fgUINT32(fgUINT32 *pn0, 
							  fgUINT32 *pn1, fgUINT32 *pn2, fgUINT32 *pn3, 
							  fgUINT32 *pn4, 
							  fgUINT32 *pdil, fgUINT32 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_9_SIMD(__m128i,4,
						  _mm_cmpeq_epi32,_mm_set1_epi32,
						  _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_9_SIMD(__m64,2,
						 _mm_cmpeq_pi32,_mm_set1_pi32, 
						 _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_9;
#endif
#endif
}




















inline void flgr_stop_label_collision_4_connex_6_fgINT8(fgINT8 *pn1,fgINT8 *pn2, fgINT8 *pn3,
							fgINT8 *pn4,
							fgINT8 *pdil, fgINT8 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_6_SIMD(__m128i,16,
						  _mm_cmpeq_epi8,_mm_set1_epi8, 
						  _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_6_SIMD(__m64,8,
						 _mm_cmpeq_pi8,_mm_set1_pi8, 
						 _mm_and_si64,_mm_or_si64);
  _mm_empty();
#else
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_6;
#endif
#endif
}


inline void flgr_stop_label_collision_4_connex_9_fgINT8(fgINT8 *pn0, 
							fgINT8 *pn1, fgINT8 *pn2, fgINT8 *pn3, 
							fgINT8 *pn4, 
							fgINT8 *pdil, fgINT8 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_9_SIMD(__m128i,16,
						  _mm_cmpeq_epi8,_mm_set1_epi8,
						  _mm_and_si128,_mm_or_si128);

#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_9_SIMD(__m64,8,
						 _mm_cmpeq_pi8,_mm_set1_pi8, 
						 _mm_and_si64,_mm_or_si64);
  _mm_empty();
#else
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_9;
#endif
#endif
}










inline void flgr_stop_label_collision_4_connex_6_fgINT16(fgINT16 *pn1,fgINT16 *pn2, fgINT16 *pn3,
							 fgINT16 *pn4,
							 fgINT16 *pdil, fgINT16 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_6_SIMD(__m128i,8,
						  _mm_cmpeq_epi16,_mm_set1_epi16,
						  _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_6_SIMD(__m64,4,
						 _mm_cmpeq_pi16,_mm_set1_pi16, 
						 _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_6;
#endif
#endif
}


inline void flgr_stop_label_collision_4_connex_9_fgINT16(fgINT16 *pn0, 
							 fgINT16 *pn1, fgINT16 *pn2, fgINT16 *pn3, 
							 fgINT16 *pn4, 
							 fgINT16 *pdil, fgINT16 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_9_SIMD(__m128i,8,
						  _mm_cmpeq_epi16,_mm_set1_epi16,
						  _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_9_SIMD(__m64,4,
						 _mm_cmpeq_pi16,_mm_set1_pi16, 
						 _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_9;
#endif
#endif
}









inline void flgr_stop_label_collision_4_connex_6_fgINT32(fgINT32 *pn1,fgINT32 *pn2, fgINT32 *pn3,
							 fgINT32 *pn4,
							 fgINT32 *pdil, fgINT32 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_6_SIMD(__m128i,4,
						  _mm_cmpeq_epi32,_mm_set1_epi32,
						  _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_6_SIMD(__m64,2,
						 _mm_cmpeq_pi32,_mm_set1_pi32, 
						 _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_6;
#endif
#endif
}


inline void flgr_stop_label_collision_4_connex_9_fgINT32(fgINT32 *pn0, 
							 fgINT32 *pn1, fgINT32 *pn2, fgINT32 *pn3, 
							 fgINT32 *pn4, 
							 fgINT32 *pdil, fgINT32 *pcenter, int length) {
#ifdef __SSE2__
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_9_SIMD(__m128i,4,
						  _mm_cmpeq_epi32,_mm_set1_epi32,
						  _mm_and_si128,_mm_or_si128);
#else
#if defined(__MMX__) && defined(__SSE__)
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_9_SIMD(__m64,2,
						 _mm_cmpeq_pi32,_mm_set1_pi32, 
						 _mm_and_si64,_mm_or_si64);
  _mm_empty();

#else
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_9;
#endif
#endif
}








inline void flgr_stop_label_collision_4_connex_6_fgFLOAT32(fgFLOAT32 *pn1,fgFLOAT32 *pn2, fgFLOAT32 *pn3,
							   fgFLOAT32 *pn4,
							   fgFLOAT32 *pdil, fgFLOAT32 *pcenter, int length) {
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_6;
}


inline void flgr_stop_label_collision_4_connex_9_fgFLOAT32(fgFLOAT32 *pn0, 
							   fgFLOAT32 *pn1, fgFLOAT32 *pn2, fgFLOAT32 *pn3, 
							   fgFLOAT32 *pn4, 
							   fgFLOAT32 *pdil, fgFLOAT32 *pcenter, int length) {
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_9;
}









inline void flgr_stop_label_collision_4_connex_6_fgFLOAT64(fgFLOAT64 *pn1,fgFLOAT64 *pn2, fgFLOAT64 *pn3,
							   fgFLOAT64 *pn4,
							   fgFLOAT64 *pdil, fgFLOAT64 *pcenter, int length) {
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_6;
}


inline void flgr_stop_label_collision_4_connex_9_fgFLOAT64(fgFLOAT64 *pn0, 
							   fgFLOAT64 *pn1, fgFLOAT64 *pn2, fgFLOAT64 *pn3, 
							   fgFLOAT64 *pn4, 
							   fgFLOAT64 *pdil, fgFLOAT64 *pcenter, int length) {
  FLGR_MACRO_STOP_LABEL_COLLISION_4_CONNEX_9;
}










































#define FLGR_MACRO_DILATE_8_CONNEXITY_SKIZ(dtype)			\
  FLGR_Data1D *neighbor[9];						\
  FLGR_Data1D *dil3 = flgr1d_create_signal_from(datsrc->row[0]);	\
  FLGR_Data1D *dil2 = flgr1d_create_signal_from(datsrc->row[0]);	\
  FLGR_Data1D *dil1 = flgr1d_create_signal_from(datsrc->row[0]);	\
  FLGR_Data1D *dil  = flgr1d_create_signal_from(datsrc->row[0]);	\
  FLGR_Data1D *tmp;							\
  FLGR_Data1D **pout = datdest->row;					\
  FLGR_Data1D **pin = datsrc->row;					\
  dtype *pdil;								\
  dtype *ptmp;								\
  dtype *pn[9];								\
  FLGR_Vector *vecmin = flgr_vector_create(datsrc->spp,datsrc->type);	\
  dtype min = MIN_##dtype;						\
  int j,k;								\
									\
  flgr_vector_populate_from_scalar_##dtype(vecmin,min);			\
									\
  neighbor[0] = flgr1d_create_signal_from(datsrc->row[0]);		\
  neighbor[1] = flgr1d_create_signal_from(datsrc->row[0]);		\
  neighbor[2] = flgr1d_create_signal_from(datsrc->row[0]);		\
  neighbor[3] = flgr1d_create_signal_from(datsrc->row[0]);		\
  neighbor[4] = flgr1d_create_signal_from(datsrc->row[0]);		\
  neighbor[5] = flgr1d_create_signal_from(datsrc->row[0]);		\
  neighbor[6] = flgr1d_create_signal_from(datsrc->row[0]);		\
  neighbor[7] = flgr1d_create_signal_from(datsrc->row[0]);		\
  neighbor[8] = flgr1d_create_signal_from(datsrc->row[0]);		\
  									\
  pn[0] = (dtype *) neighbor[0]->array;					\
  pn[1] = (dtype *) neighbor[1]->array;					\
  pn[2] = (dtype *) neighbor[2]->array;					\
  pn[3] = (dtype *) neighbor[3]->array;					\
  pn[4] = (dtype *) neighbor[4]->array;					\
  pn[5] = (dtype *) neighbor[5]->array;					\
  pn[6] = (dtype *) neighbor[6]->array;					\
  pn[7] = (dtype *) neighbor[7]->array;					\
  pn[8] = (dtype *) neighbor[8]->array;					\
  									\
  flgr1d_copy_##dtype##_##dtype(neighbor[4],pin[0]);			\
  flgr1d_copy_##dtype##_##dtype(neighbor[7],pin[1]);			\
  flgr1d_shift_right_##dtype(neighbor[3],neighbor[4],1,vecmin);		\
  flgr1d_shift_right_##dtype(neighbor[6],neighbor[7],1,vecmin);		\
  flgr1d_shift_left_##dtype(neighbor[5],neighbor[4],1,vecmin);		\
  flgr1d_shift_left_##dtype(neighbor[8],neighbor[7],1,vecmin);		\
									\
  flgr1d_arith_sup_##dtype(dil2,neighbor[4],neighbor[3]);		\
  flgr1d_arith_sup_##dtype(dil2,dil2,neighbor[5]);			\
									\
  flgr1d_arith_sup_##dtype(dil3,neighbor[6],neighbor[7]);		\
  flgr1d_arith_sup_##dtype(dil3,dil3,neighbor[8]);			\
									\
  flgr1d_arith_sup_##dtype(pout[0],dil2,dil3);				\
  									\
  pdil = pout[0]->array;						\
  									\
  flgr_stop_label_collision_8_connex_6_##dtype(pn[3],pn[4],pn[5],	\
					       pn[6],pn[7],pn[8],	\
					       pdil,pn[4],		\
					       dil->length);		\
									\
  for(k=1,j=2 ; j<datsrc->size_y ; k++,j++) {				\
									\
    tmp = neighbor[0];	     ptmp=pn[0];				\
    neighbor[0]=neighbor[3]; pn[0]=pn[3];				\
    neighbor[3]=neighbor[6]; pn[3]=pn[6];				\
    neighbor[6]=tmp;         pn[6]=ptmp;				\
 									\
    tmp = neighbor[1];	     ptmp=pn[1];				\
    neighbor[1]=neighbor[4]; pn[1]=pn[4];				\
    neighbor[4]=neighbor[7]; pn[4]=pn[7];				\
    neighbor[7]=tmp;         pn[7]=ptmp;				\
 									\
    tmp = neighbor[2];	     ptmp=pn[2];				\
    neighbor[2]=neighbor[5]; pn[2]=pn[5];				\
    neighbor[5]=neighbor[8]; pn[5]=pn[8];				\
    neighbor[8]=tmp;         pn[8]=ptmp;				\
 									\
    tmp = dil1;								\
    dil1 = dil2;							\
    dil2 = dil3;							\
    dil3 = tmp;								\
 									\
    flgr1d_copy_##dtype##_##dtype(neighbor[7],pin[j]);			\
    flgr1d_shift_right_##dtype(neighbor[6],neighbor[7],1,vecmin);	\
    flgr1d_shift_left_##dtype(neighbor[8],neighbor[7],1,vecmin);	\
   									\
    flgr1d_arith_sup_##dtype(dil3,neighbor[6],neighbor[7]);		\
    flgr1d_arith_sup_##dtype(dil3,dil3,neighbor[8]);			\
									\
    flgr1d_arith_sup_##dtype(pout[k],dil2,dil3);			\
    flgr1d_arith_sup_##dtype(pout[k],pout[k],dil1);			\
   									\
    pdil = pout[k]->array;						\
    									\
    flgr_stop_label_collision_8_connex_9_##dtype(pn[0],pn[1],pn[2],	\
						 pn[3],pn[4],pn[5],	\
						 pn[6],pn[7],pn[8],	\
						 pdil,pn[4],		\
						 dil->length);		\
   									\
  }									\
									\
  tmp = neighbor[0];	     ptmp=pn[0];				\
  neighbor[0]=neighbor[3]; pn[0]=pn[3];					\
  neighbor[3]=neighbor[6]; pn[3]=pn[6];					\
  neighbor[6]=tmp;         pn[6]=ptmp;					\
 									\
  tmp = neighbor[1];	     ptmp=pn[1];				\
  neighbor[1]=neighbor[4]; pn[1]=pn[4];					\
  neighbor[4]=neighbor[7]; pn[4]=pn[7];					\
  neighbor[7]=tmp;         pn[7]=ptmp;					\
 									\
  tmp = neighbor[2];	     ptmp=pn[2];				\
  neighbor[2]=neighbor[5]; pn[2]=pn[5];					\
  neighbor[5]=neighbor[8]; pn[5]=pn[8];					\
  neighbor[8]=tmp;         pn[8]=ptmp;					\
 									\
  tmp = dil1;								\
  dil1 = dil2;								\
  dil2 = dil3;								\
  dil3 = tmp;								\
 									\
  flgr1d_arith_sup_##dtype(pout[k],dil1,dil2);				\
  pdil = pout[k]->array;						\
									\
  flgr_stop_label_collision_8_connex_6_##dtype(pn[0],pn[1],pn[2],	\
					       pn[3],pn[4],pn[5],	\
					       pdil,pn[4],		\
					       dil->length);		\
 									\
									\
  flgr1d_destroy(neighbor[0]);						\
  flgr1d_destroy(neighbor[1]);						\
  flgr1d_destroy(neighbor[2]);						\
  flgr1d_destroy(neighbor[3]);						\
  flgr1d_destroy(neighbor[4]);						\
  flgr1d_destroy(neighbor[5]);						\
  flgr1d_destroy(neighbor[6]);						\
  flgr1d_destroy(neighbor[7]);						\
  flgr1d_destroy(neighbor[8]);						\
									\
  flgr1d_destroy(dil1);							\
  flgr1d_destroy(dil2);							\
  flgr1d_destroy(dil3);							\
  flgr1d_destroy(dil);							\
  flgr_vector_destroy(vecmin)





void flgr2d_dilate_preserving_skiz_fast_8_connex_fgUINT8(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
  FLGR_DECLARE_FUNCTION;
  FLGR_MACRO_DILATE_8_CONNEXITY_SKIZ(fgUINT8);
}

void flgr2d_dilate_preserving_skiz_fast_8_connex_fgUINT16(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
  FLGR_DECLARE_FUNCTION;
  FLGR_MACRO_DILATE_8_CONNEXITY_SKIZ(fgUINT16);
}

void flgr2d_dilate_preserving_skiz_fast_8_connex_fgUINT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
  FLGR_DECLARE_FUNCTION;
  FLGR_MACRO_DILATE_8_CONNEXITY_SKIZ(fgUINT32);
}

void flgr2d_dilate_preserving_skiz_fast_8_connex_fgINT8(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
  FLGR_DECLARE_FUNCTION;
  FLGR_MACRO_DILATE_8_CONNEXITY_SKIZ(fgINT8);
}

void flgr2d_dilate_preserving_skiz_fast_8_connex_fgINT16(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
  FLGR_DECLARE_FUNCTION;
  FLGR_MACRO_DILATE_8_CONNEXITY_SKIZ(fgINT16);
}

void flgr2d_dilate_preserving_skiz_fast_8_connex_fgINT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
  FLGR_DECLARE_FUNCTION;
  FLGR_MACRO_DILATE_8_CONNEXITY_SKIZ(fgINT32);
}

void flgr2d_dilate_preserving_skiz_fast_8_connex_fgFLOAT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
  FLGR_DECLARE_FUNCTION;
  FLGR_MACRO_DILATE_8_CONNEXITY_SKIZ(fgFLOAT32);
}

void flgr2d_dilate_preserving_skiz_fast_8_connex_fgFLOAT64(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
  FLGR_DECLARE_FUNCTION;
  FLGR_MACRO_DILATE_8_CONNEXITY_SKIZ(fgFLOAT64);
}

















#define FLGR_MACRO_DILATE_4_CONNEXITY_SKIZ(dtype)			\
  FLGR_Data1D *neighbor[5];						\
  FLGR_Data1D *dil1 = flgr1d_create_signal_from(datsrc->row[0]);	\
  FLGR_Data1D *dil2 = flgr1d_create_signal_from(datsrc->row[0]);	\
  FLGR_Data1D *tmp;							\
  FLGR_Data1D **pout = datdest->row;					\
  FLGR_Data1D **pin = datsrc->row;					\
  dtype *pdil;								\
  dtype *ptmp;								\
  dtype *pn[5];								\
  FLGR_Vector *vecmin = flgr_vector_create(datsrc->spp,datsrc->type);	\
  dtype min = MIN_##dtype;						\
  int j,k,length = dil1->length;					\
									\
  flgr_vector_populate_from_scalar_##dtype(vecmin,min);			\
									\
  neighbor[0] = flgr1d_create_signal_from(datsrc->row[0]);		\
  neighbor[1] = flgr1d_create_signal_from(datsrc->row[0]);		\
  neighbor[2] = flgr1d_create_signal_from(datsrc->row[0]);		\
  neighbor[3] = flgr1d_create_signal_from(datsrc->row[0]);		\
  neighbor[4] = flgr1d_create_signal_from(datsrc->row[0]);		\
  									\
  pn[0] = (dtype *) neighbor[0]->array;					\
  pn[1] = (dtype *) neighbor[1]->array;					\
  pn[2] = (dtype *) neighbor[2]->array;					\
  pn[3] = (dtype *) neighbor[3]->array;					\
  pn[4] = (dtype *) neighbor[4]->array;					\
  									\
  flgr1d_copy_##dtype##_##dtype(neighbor[2],pin[0]);			\
  flgr1d_copy_##dtype##_##dtype(neighbor[4],pin[1]);			\
  flgr1d_shift_right_##dtype(neighbor[1],neighbor[2],1,vecmin);		\
  flgr1d_shift_left_##dtype(neighbor[3],neighbor[2],1,vecmin);		\
									\
  flgr1d_arith_sup_##dtype(dil1,neighbor[1],neighbor[2]);		\
  flgr1d_arith_sup_##dtype(dil2,neighbor[3],neighbor[4]);		\
  flgr1d_arith_sup_##dtype(pout[0],dil1,dil2);				\
									\
  pdil = pout[0]->array;						\
  									\
  flgr_stop_label_collision_4_connex_6_##dtype(pn[1],pn[2],		\
					       pn[3],pn[4],		\
					       pdil,pn[2],		\
					       length);			\
									\
  for(k=1,j=2 ; j<datsrc->size_y ; k++,j++) {				\
									\
    tmp = neighbor[0];	     ptmp=pn[0];				\
    neighbor[0]=neighbor[2]; pn[0]=pn[2];				\
    neighbor[2]=neighbor[4]; pn[2]=pn[4];				\
    neighbor[4]=tmp;         pn[4]=ptmp;				\
 									\
    flgr1d_copy_##dtype##_##dtype(neighbor[4],pin[j]);			\
    flgr1d_shift_right_##dtype(neighbor[1],neighbor[2],1,vecmin);	\
    flgr1d_shift_left_##dtype(neighbor[3],neighbor[2],1,vecmin);	\
   									\
    flgr1d_arith_sup_##dtype(dil1,neighbor[0],neighbor[1]);		\
    flgr1d_arith_sup_##dtype(dil2,neighbor[2],neighbor[3]);		\
    flgr1d_arith_sup_##dtype(pout[k],dil1,dil2);			\
    flgr1d_arith_sup_##dtype(pout[k],pout[k],neighbor[4]);		\
   									\
    pdil = pout[k]->array;						\
    									\
    flgr_stop_label_collision_4_connex_9_##dtype(pn[0],			\
						 pn[1],			\
						 pn[2],			\
						 pn[3],			\
						 pn[4],			\
						 pdil,pn[2],		\
						 length);		\
   									\
  }									\
									\
  tmp = neighbor[0];	   ptmp=pn[0];					\
  neighbor[0]=neighbor[2]; pn[0]=pn[2];					\
  neighbor[2]=neighbor[4]; pn[2]=pn[4];					\
  neighbor[4]=tmp;         pn[4]=ptmp;					\
 									\
  flgr1d_shift_right_##dtype(neighbor[1],neighbor[2],1,vecmin);		\
  flgr1d_shift_left_##dtype(neighbor[3],neighbor[2],1,vecmin);		\
   									\
  flgr1d_arith_sup_##dtype(dil1,neighbor[0],neighbor[1]);		\
  flgr1d_arith_sup_##dtype(dil2,neighbor[2],neighbor[3]);		\
  flgr1d_arith_sup_##dtype(pout[k],dil1,dil2);				\
  pdil = pout[k]->array;						\
									\
  flgr_stop_label_collision_4_connex_6_##dtype(pn[0],pn[1],		\
					       pn[2],pn[3],		\
					       pdil,pn[2],		\
					       length);			\
 									\
									\
  flgr1d_destroy(neighbor[0]);						\
  flgr1d_destroy(neighbor[1]);						\
  flgr1d_destroy(neighbor[2]);						\
  flgr1d_destroy(neighbor[3]);						\
  flgr1d_destroy(neighbor[4]);						\
									\
  flgr1d_destroy(dil1);							\
  flgr1d_destroy(dil2);							\
  flgr_vector_destroy(vecmin)





void flgr2d_dilate_preserving_skiz_fast_4_connex_fgUINT8(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
  FLGR_DECLARE_FUNCTION;
  FLGR_MACRO_DILATE_4_CONNEXITY_SKIZ(fgUINT8);
}

void flgr2d_dilate_preserving_skiz_fast_4_connex_fgUINT16(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
  FLGR_DECLARE_FUNCTION;
  FLGR_MACRO_DILATE_4_CONNEXITY_SKIZ(fgUINT16);
}

void flgr2d_dilate_preserving_skiz_fast_4_connex_fgUINT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
  FLGR_DECLARE_FUNCTION;
  FLGR_MACRO_DILATE_4_CONNEXITY_SKIZ(fgUINT32);
}

void flgr2d_dilate_preserving_skiz_fast_4_connex_fgINT8(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
  FLGR_DECLARE_FUNCTION;
  FLGR_MACRO_DILATE_4_CONNEXITY_SKIZ(fgINT8);
}

void flgr2d_dilate_preserving_skiz_fast_4_connex_fgINT16(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
  FLGR_DECLARE_FUNCTION;
  FLGR_MACRO_DILATE_4_CONNEXITY_SKIZ(fgINT16);
}

void flgr2d_dilate_preserving_skiz_fast_4_connex_fgINT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
  FLGR_DECLARE_FUNCTION;
  FLGR_MACRO_DILATE_4_CONNEXITY_SKIZ(fgINT32);
}

void flgr2d_dilate_preserving_skiz_fast_4_connex_fgFLOAT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
  FLGR_DECLARE_FUNCTION;
  FLGR_MACRO_DILATE_4_CONNEXITY_SKIZ(fgFLOAT32);
}

void flgr2d_dilate_preserving_skiz_fast_4_connex_fgFLOAT64(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
  FLGR_DECLARE_FUNCTION;
  FLGR_MACRO_DILATE_4_CONNEXITY_SKIZ(fgFLOAT64);
}


















#define FLGR_MACRO_DILATE_6_CONNEXITY_SKIZ(dtype)			\
  FLGR_Data1D *neighbor[9];						\
  FLGR_Data1D *dil1 = flgr1d_create_signal_from(datsrc->row[0]);	\
  FLGR_Data1D *dil2 = flgr1d_create_signal_from(datsrc->row[0]);	\
  FLGR_Data1D *dil3 = flgr1d_create_signal_from(datsrc->row[0]);	\
  FLGR_Data1D *tmp;							\
  FLGR_Data1D **pout = datdest->row;					\
  FLGR_Data1D **pin = datsrc->row;					\
  dtype *pdil;								\
  dtype *ptmp;								\
  dtype *pn[9];								\
  FLGR_Vector *vecmin = flgr_vector_create(datsrc->spp,datsrc->type);	\
  dtype min = MIN_##dtype;						\
  int j,k;								\
  int length = dil1->length;						\
									\
  flgr_vector_populate_from_scalar_##dtype(vecmin,min);			\
									\
  neighbor[0] = flgr1d_create_signal_from(datsrc->row[0]);		\
  neighbor[1] = flgr1d_create_signal_from(datsrc->row[0]);		\
  neighbor[2] = flgr1d_create_signal_from(datsrc->row[0]);		\
  neighbor[3] = flgr1d_create_signal_from(datsrc->row[0]);		\
  neighbor[4] = flgr1d_create_signal_from(datsrc->row[0]);		\
  neighbor[5] = flgr1d_create_signal_from(datsrc->row[0]);		\
  neighbor[6] = flgr1d_create_signal_from(datsrc->row[0]);		\
  neighbor[7] = flgr1d_create_signal_from(datsrc->row[0]);		\
  neighbor[8] = flgr1d_create_signal_from(datsrc->row[0]);		\
  									\
  pn[0] = (dtype *) neighbor[0]->array;					\
  pn[1] = (dtype *) neighbor[1]->array;					\
  pn[2] = (dtype *) neighbor[2]->array;					\
  pn[3] = (dtype *) neighbor[3]->array;					\
  pn[4] = (dtype *) neighbor[4]->array;					\
  pn[5] = (dtype *) neighbor[5]->array;					\
  pn[6] = (dtype *) neighbor[6]->array;					\
  pn[7] = (dtype *) neighbor[7]->array;					\
  pn[8] = (dtype *) neighbor[8]->array;					\
  									\
  flgr1d_copy_##dtype##_##dtype(neighbor[4],pin[0]);			\
  flgr1d_copy_##dtype##_##dtype(neighbor[7],pin[1]);			\
  flgr1d_shift_right_##dtype(neighbor[3],neighbor[4],1,vecmin);		\
  flgr1d_shift_left_##dtype(neighbor[5],neighbor[4],1,vecmin);		\
  flgr1d_shift_right_##dtype(neighbor[6],neighbor[7],1,vecmin);		\
  flgr1d_shift_left_##dtype(neighbor[8],neighbor[7],1,vecmin);		\
									\
  flgr1d_arith_sup_##dtype(dil2,neighbor[3],neighbor[4]);		\
  flgr1d_arith_sup_##dtype(dil3,neighbor[5],neighbor[7]);		\
  flgr1d_arith_sup_##dtype(pout[0],dil2,dil3);				\
  flgr1d_arith_sup_##dtype(pout[0],pout[0],neighbor[8]);		\
									\
  pdil = pout[0]->array;						\
  									\
  flgr_stop_label_collision_6_connex_p1_6_##dtype(pn[3],pn[4],pn[5],	\
						  pn[7],pn[8],		\
						  pdil,pn[4],		\
						  length);		\
									\
  for(k=1,j=2 ; j<datsrc->size_y ; k++,j++) {				\
									\
    tmp = neighbor[0];	     ptmp=pn[0];				\
    neighbor[0]=neighbor[3]; pn[0]=pn[3];				\
    neighbor[3]=neighbor[6]; pn[3]=pn[6];				\
    neighbor[6]=tmp;         pn[6]=ptmp;				\
									\
    tmp = neighbor[1];	     ptmp=pn[1];				\
    neighbor[1]=neighbor[4]; pn[1]=pn[4];				\
    neighbor[4]=neighbor[7]; pn[4]=pn[7];				\
    neighbor[7]=tmp;         pn[7]=ptmp;				\
									\
    tmp = neighbor[2];	     ptmp=pn[2];				\
    neighbor[2]=neighbor[5]; pn[2]=pn[5];				\
    neighbor[5]=neighbor[8]; pn[5]=pn[8];				\
    neighbor[8]=tmp;         pn[8]=ptmp;				\
									\
    flgr1d_copy_##dtype##_##dtype(neighbor[7],pin[j]);			\
    flgr1d_shift_right_##dtype(neighbor[6],neighbor[7],1,vecmin);	\
    flgr1d_shift_left_##dtype(neighbor[8],neighbor[7],1,vecmin);	\
									\
    pdil = pout[k]->array;						\
									\
    if(k%2==0) {							\
      flgr1d_arith_sup_##dtype(dil1,neighbor[1],neighbor[2]);		\
      flgr1d_arith_sup_##dtype(dil2,neighbor[3],neighbor[4]);		\
      flgr1d_arith_sup_##dtype(dil3,neighbor[5],neighbor[7]);		\
      flgr1d_arith_sup_##dtype(pout[k],dil1,dil2);			\
      flgr1d_arith_sup_##dtype(pout[k],pout[k],dil3);			\
      flgr1d_arith_sup_##dtype(pout[k],pout[k],neighbor[8]);		\
 									\
      flgr_stop_label_collision_6_connex_p1_9_##dtype(  pn[1],pn[2],	\
							pn[3],pn[4],pn[5], \
						        pn[7],pn[8],	\
							pdil,pn[4],	\
							length);	\
									\
    }else {								\
      flgr1d_arith_sup_##dtype(dil1,neighbor[0],neighbor[1]);		\
      flgr1d_arith_sup_##dtype(dil2,neighbor[3],neighbor[4]);		\
      flgr1d_arith_sup_##dtype(dil3,neighbor[5],neighbor[7]);		\
      flgr1d_arith_sup_##dtype(pout[k],dil1,dil2);			\
      flgr1d_arith_sup_##dtype(pout[k],pout[k],dil3);			\
      flgr1d_arith_sup_##dtype(pout[k],pout[k],neighbor[6]);		\
 									\
      flgr_stop_label_collision_6_connex_p2_9_##dtype(  pn[0],pn[1],	\
							pn[3],pn[4],pn[5], \
						        pn[6],pn[7],	\
							pdil,pn[4],	\
							length);	\
									\
    }									\
  									\
  }									\
									\
 									\
  tmp = neighbor[0];	     ptmp=pn[0];				\
  neighbor[0]=neighbor[3]; pn[0]=pn[3];					\
  neighbor[3]=neighbor[6]; pn[3]=pn[6];					\
  neighbor[6]=tmp;         pn[6]=ptmp;					\
									\
  tmp = neighbor[1];	     ptmp=pn[1];				\
  neighbor[1]=neighbor[4]; pn[1]=pn[4];					\
  neighbor[4]=neighbor[7]; pn[4]=pn[7];					\
  neighbor[7]=tmp;         pn[7]=ptmp;					\
									\
  tmp = neighbor[2];	     ptmp=pn[2];				\
  neighbor[2]=neighbor[5]; pn[2]=pn[5];					\
  neighbor[5]=neighbor[8]; pn[5]=pn[8];					\
  neighbor[8]=tmp;         pn[8]=ptmp;					\
									\
  pdil = pout[k]->array;						\
  if(k%2==0) {								\
    flgr1d_arith_sup_##dtype(dil1,neighbor[1],neighbor[2]);		\
    flgr1d_arith_sup_##dtype(dil2,neighbor[3],neighbor[4]);		\
    flgr1d_arith_sup_##dtype(pout[k],dil1,dil2);			\
    flgr1d_arith_sup_##dtype(pout[k],pout[k],neighbor[5]);		\
									\
    flgr_stop_label_collision_6_connex_p1_6_##dtype(pn[3],pn[4],pn[5],	\
						    pn[1],pn[2],	\
						    pdil,pn[4],		\
						    length);		\
									\
  }else {								\
    flgr1d_arith_sup_##dtype(dil1,neighbor[0],neighbor[1]);		\
    flgr1d_arith_sup_##dtype(dil2,neighbor[3],neighbor[4]);		\
    flgr1d_arith_sup_##dtype(pout[k],dil1,dil2);			\
    flgr1d_arith_sup_##dtype(pout[k],pout[k],neighbor[5]);		\
 									\
    flgr_stop_label_collision_6_connex_p2_6_##dtype(pn[3],pn[4],pn[5],	\
						    pn[0],pn[1],	\
						    pdil,pn[4],		\
						    length);		\
									\
  }									\
 									\
									\
  flgr1d_destroy(neighbor[0]);						\
  flgr1d_destroy(neighbor[1]);						\
  flgr1d_destroy(neighbor[2]);						\
  flgr1d_destroy(neighbor[3]);						\
  flgr1d_destroy(neighbor[4]);						\
  flgr1d_destroy(neighbor[5]);						\
  flgr1d_destroy(neighbor[6]);						\
  flgr1d_destroy(neighbor[7]);						\
  flgr1d_destroy(neighbor[8]);						\
									\
  flgr1d_destroy(dil1);							\
  flgr1d_destroy(dil2);							\
  flgr1d_destroy(dil3);							\
  flgr_vector_destroy(vecmin)





void flgr2d_dilate_preserving_skiz_fast_6_connex_fgUINT8(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
  FLGR_DECLARE_FUNCTION;
  FLGR_MACRO_DILATE_6_CONNEXITY_SKIZ(fgUINT8);
}

void flgr2d_dilate_preserving_skiz_fast_6_connex_fgUINT16(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
  FLGR_DECLARE_FUNCTION;
  FLGR_MACRO_DILATE_6_CONNEXITY_SKIZ(fgUINT16);
}

void flgr2d_dilate_preserving_skiz_fast_6_connex_fgUINT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
  FLGR_DECLARE_FUNCTION;
  FLGR_MACRO_DILATE_6_CONNEXITY_SKIZ(fgUINT32);
}

void flgr2d_dilate_preserving_skiz_fast_6_connex_fgINT8(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
  FLGR_DECLARE_FUNCTION;
  FLGR_MACRO_DILATE_6_CONNEXITY_SKIZ(fgINT8);
}

void flgr2d_dilate_preserving_skiz_fast_6_connex_fgINT16(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
  FLGR_DECLARE_FUNCTION;
  FLGR_MACRO_DILATE_6_CONNEXITY_SKIZ(fgINT16);
}

void flgr2d_dilate_preserving_skiz_fast_6_connex_fgINT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
  FLGR_DECLARE_FUNCTION;
  FLGR_MACRO_DILATE_6_CONNEXITY_SKIZ(fgINT32);
}

void flgr2d_dilate_preserving_skiz_fast_6_connex_fgFLOAT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
  FLGR_DECLARE_FUNCTION;
  FLGR_MACRO_DILATE_6_CONNEXITY_SKIZ(fgFLOAT32);
}

void flgr2d_dilate_preserving_skiz_fast_6_connex_fgFLOAT64(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
  FLGR_DECLARE_FUNCTION;
  FLGR_MACRO_DILATE_6_CONNEXITY_SKIZ(fgFLOAT64);
}


